package com.pdg.mcplugin.tsa;

import org.bukkit.command.CommandSender;

import com.pdg.mcplugin.common.ArgumentList;
import com.pdg.mcplugin.common.baseclasses.CommandProcessorBase;

public class CommandProcessor extends CommandProcessorBase<TSA> {

	private static final String SUBCOMMAND_ARRIVALSIGN = "ARRIVALSIGN";
	private static final String SUBCOMMAND_DEPARTURESIGN = "DEPARTURESIGN";
	private static final String[] LINES_ARRIVALSIGN = new String[]{
		"To create an arrival sign:",
		"Line 1: [tsa]",
		"Line 2: arrival",
		"Line 3: (name)",
		"Line 4: (contraband list)",
		"(contraband list) is optional. Unknown contraband lists will use the default contraband list."
	};

	private static final String[] LINES_DEPARTURESIGN = new String[]{
		"To create a departure sign:",
		"Line 1: [tsa]",
		"Line 2: departure",
		"Line 3: (arrival name)",
		"Line 4: (cost)",
		"(cost) is optional."
	};
	private static final String KEY_CONTRABAND = "CONTRABAND";

	public CommandProcessor(TSA thePlugin) {
		super(thePlugin, new String[]{
				"/tsa - general help for TSA (you are here)",
				"/tsa arrivalsign - help for arrival signs",
				"/tsa departuresign - help for departure signs",
				"/tsa contraband - help for contraband"
		});
		this.setSubProcessor(KEY_CONTRABAND, new ContrabandCommandProcessor(this));
	}

	@Override
	protected boolean specialProcessCommand(CommandSender theCommandSender,
			String theSubCommand, ArgumentList theArgumentList) {
		if(theSubCommand.equalsIgnoreCase(SUBCOMMAND_ARRIVALSIGN)){
			return showArrivalSignHelp(theCommandSender);
		}else if(theSubCommand.equalsIgnoreCase(SUBCOMMAND_DEPARTURESIGN)){
			return showDepartureSignHelp(theCommandSender);
		}else{
			return false;
		}
	}

	private boolean showDepartureSignHelp(CommandSender theCommandSender) {
		getPlugin().sendInformationalMessages(theCommandSender, LINES_DEPARTURESIGN);
		return true;
	}

	private boolean showArrivalSignHelp(CommandSender theCommandSender) {
		getPlugin().sendInformationalMessages(theCommandSender, LINES_ARRIVALSIGN);
		return true;
	}

}
